<html>
<head><meta charset="utf-8"><title>57893 coherence · t-lang · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/index.html">t-lang</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/57893.20coherence.html">57893 coherence</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="185520353"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/57893%20coherence/near/185520353" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/57893.20coherence.html#185520353">(Jan 13 2020 at 18:21)</a>:</h4>
<p>Hmm, <span class="user-group-mention" data-user-group-id="1977">@T-lang</span>, thinking more about <a href="https://github.com/rust-lang/rust/issues/57893" target="_blank" title="https://github.com/rust-lang/rust/issues/57893">#57893</a>, it occurs to me that <em>another</em> potential solution -- one that is perhaps safer in the short term -- is to say that a trait <code>T</code> is not dyn-safe if:</p>
<ul>
<li>it has a "potentially dyn-overlapping impl" <em>and</em> it has associated items that are not fns</li>
</ul>
<p>That, coupled with saying that all fns in a dyn-overlapping impl are (conceptually, at least) <code>default</code>, would be a fairly targeted change, and would not (I think) be very likely to break anyone. In particular it obviates the concern about traits that "just happen" to be dyn-safe being forced to use <code>default</code>.</p>



<a name="185520373"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/57893%20coherence/near/185520373" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/57893.20coherence.html#185520373">(Jan 13 2020 at 18:21)</a>:</h4>
<p>It does mean of course that the dyn-safe rules are getting increasingly arcane</p>



<a name="185520381"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/57893%20coherence/near/185520381" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/57893.20coherence.html#185520381">(Jan 13 2020 at 18:21)</a>:</h4>
<p>But that's kind of true regardless</p>



<a name="185520533"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/57893%20coherence/near/185520533" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/57893.20coherence.html#185520533">(Jan 13 2020 at 18:22)</a>:</h4>
<p>Under this change, I think that all of the breakage I saw in practice would be removed, but I can test that</p>



<a name="185521216"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/57893%20coherence/near/185521216" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/57893.20coherence.html#185521216">(Jan 13 2020 at 18:29)</a>:</h4>
<p>(I'm experimenting with this change now, should be fairly easy to implement.)</p>



<a name="185523303"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/57893%20coherence/near/185523303" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/57893.20coherence.html#185523303">(Jan 13 2020 at 18:47)</a>:</h4>
<blockquote>
<p>trait <code>T</code> is not dyn-safe if: it has a  "potentially dyn-overlapping impl" and it has associated items that are not fns</p>
</blockquote>
<p>nit: associated items that are not fns which do not have a <code>where Self: Sized</code> bound, right?</p>



<a name="185523400"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/57893%20coherence/near/185523400" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/57893.20coherence.html#185523400">(Jan 13 2020 at 18:48)</a>:</h4>
<p>mm I don't think so</p>



<a name="185523433"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/57893%20coherence/near/185523433" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/57893.20coherence.html#185523433">(Jan 13 2020 at 18:48)</a>:</h4>
<p>I guess maybe eventually</p>



<a name="185523461"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/57893%20coherence/near/185523461" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/57893.20coherence.html#185523461">(Jan 13 2020 at 18:48)</a>:</h4>
<p>but that would be like <code>trait Foo { type X where Self: Sized; }</code></p>



<a name="185523472"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/57893%20coherence/near/185523472" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/57893.20coherence.html#185523472">(Jan 13 2020 at 18:48)</a>:</h4>
<p>which, without GATs, we don't even really support</p>



<a name="185523499"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/57893%20coherence/near/185523499" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/57893.20coherence.html#185523499">(Jan 13 2020 at 18:49)</a>:</h4>
<p>or hmm</p>



<a name="185523575"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/57893%20coherence/near/185523575" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/57893.20coherence.html#185523575">(Jan 13 2020 at 18:49)</a>:</h4>
<p>or are you saying that if you have a <code>where Self: Sized</code> fn, that is potentially a problem? I don't think it is -- it's not present in the vtable, but it's also not invokable on a <code>dyn Trait</code> type</p>



<a name="185523576"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/57893%20coherence/near/185523576" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/57893.20coherence.html#185523576">(Jan 13 2020 at 18:49)</a>:</h4>
<p>I definitely have reasons why I would want that to be supported.</p>



<a name="185523602"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/57893%20coherence/near/185523602" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/57893.20coherence.html#185523602">(Jan 13 2020 at 18:49)</a>:</h4>
<p>^^ no, your example <code>Foo</code> is similar to what I had in mind.</p>



<a name="185523833"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/57893%20coherence/near/185523833" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/57893.20coherence.html#185523833">(Jan 13 2020 at 18:52)</a>:</h4>
<blockquote>
<p>I definitely have reasons why I would want that to be supported.</p>
</blockquote>
<p>(e.g. a method with a <code>where Self: Sized</code> bound that returns a <code>where Self: Sized</code> associated type)</p>



<a name="185524182"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/57893%20coherence/near/185524182" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/57893.20coherence.html#185524182">(Jan 13 2020 at 18:55)</a>:</h4>
<p>ok, well, I agree we could add that caveat</p>



<a name="185554164"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/57893%20coherence/near/185554164" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/57893.20coherence.html#185554164">(Jan 14 2020 at 00:41)</a>:</h4>
<p>I updated <a href="https://github.com/rust-lang/rust/pull/66037" target="_blank" title="https://github.com/rust-lang/rust/pull/66037">https://github.com/rust-lang/rust/pull/66037</a> with this idea -- not <span class="user-mention" data-user-id="127859">@Taylor Cramer</span>'s variant, just the basic one, but I think we could extend it</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>